import java.nio.ByteBuffer;

import sk.upjs.gursky.bplustree.BPObject;

public class NeklastrovanyZaznam implements BPObject<Kluc, NeklastrovanyZaznam> {
	
	private static final long serialVersionUID = 62515777079921495L;
	
	private long offset;
	private String priezvisko;
	
	public NeklastrovanyZaznam() {
	}
	
	@Override
	public int compareTo(NeklastrovanyZaznam arg0) {
		return this.priezvisko.compareTo(arg0.priezvisko);
	}
	
	@Override
	public void load(ByteBuffer bb) {
		char[] data = new char[10];		
		for (int i = 0; i < 10; i++) {
			data[i] = bb.getChar();
		}
		priezvisko = new String(data);
		offset = bb.getLong();
	}
	
	@Override
	public void save(ByteBuffer bb) {
		for (int k = 0; k < 10; k++) {
			bb.putChar(priezvisko.charAt(k));
		}
		bb.putLong(offset);
	}

	@Override
	public int getSize() {
		return 28;
	}
	
	@Override
	public Kluc getKey() {
		return new Kluc(priezvisko);
	}
	
	public void setOffset(long offset) {
		this.offset = offset;
	}
	
	public void setPriezvisko(String priezvisko) {
		this.priezvisko = priezvisko;
	}
	
	public long getOffset() {
		return offset;
	}
}
